using System;
using System.Collections;
using System.Data;
using System.Data.SqlClient;

/// <summary>
/// Summary description for SqlServerObjectProvider
/// </summary>
public partial class SqlServerProvider
{
	 
 
    public object[] GetObject( )
    {
        object[] obj = null;
        sqlCommand = new SqlCommand();
        sqlCommand.CommandText = commandText;
        sqlCommand.Connection = sqlConnection;
        sqlCommand.CommandType = commandType;

        if (ParameterCollection != null)
            AddParameters(sqlCommand);
        SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();

        if (sqlDataReader.Read())
        {
            obj = new object[sqlDataReader.FieldCount];
            sqlDataReader.GetValues(obj);
        }
        sqlDataReader.Close();
        sqlCommand.Dispose();
        return obj;
    }
    public string[] GetStrings( )
    {
        string[] str = null;
        sqlCommand = new SqlCommand();
        sqlCommand.CommandText = commandText;
        sqlCommand.Connection = sqlConnection;
        sqlCommand.CommandType = commandType;

        if (ParameterCollection != null)
            AddParameters(sqlCommand);
        SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
        str = new string[sqlDataReader.FieldCount];
        if (sqlDataReader.Read())
        {
            for (int i = 0; i < sqlDataReader.FieldCount; i++)
            {
                str[i] = Convert.ToString(sqlDataReader[i]);
            }
        }
        sqlDataReader.Close();
        sqlCommand.Dispose();
        return str;
    }
     
    public ArrayList GetArrayList()
    {
        ArrayList arrayList = new ArrayList();
        string[] stringValue = null;
        sqlCommand = new SqlCommand();
        sqlCommand.CommandText = commandText;
        sqlCommand.Connection = sqlConnection;
        sqlCommand.CommandType = commandType;
        if (ParameterCollection != null)
            AddParameters(sqlCommand);
        SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
        int cols = sqlDataReader.FieldCount;

        while (sqlDataReader.Read())
        {
            stringValue = new string[cols];
            for (int i = 0; i < cols; i++)
            {
                stringValue[i] = Convert.ToString(sqlDataReader[i]);
            }
            arrayList.Add(stringValue);
        }
        sqlDataReader.Close();
        sqlCommand.Dispose();
        return arrayList;
    }
}
